package com.xuelang.pipeline.artifact.entry.resource;

import com.xuelang.pipeline.artifact.app.resource.ArtifactProxyService;
import com.xuelang.pipeline.artifact.client.common.request.PageParam;
import com.xuelang.pipeline.artifact.client.common.result.ApiResult;
import com.xuelang.pipeline.artifact.client.common.result.PageRecord;
import com.xuelang.pipeline.artifact.client.resource.IArtifactProxyService;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactProxyDTO;
import com.xuelang.pipeline.artifact.client.resource.dto.ArtifactProxyQuery;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 制品仓库代理web控制类
 *
 * @author xiwen.zxg
 * @since 2024/5/15
 */
@Slf4j
@RestController
@RequestMapping("/artifact-proxy")
public class ArtifactProxyController implements IArtifactProxyService {

    @Autowired
    private ArtifactProxyService artifactProxyService;

    @Override
    public ApiResult<PageRecord<ArtifactProxyDTO>> pageArtifactProxyList(PageParam<ArtifactProxyQuery> dtoPageParam) {
        return ApiResult.success(artifactProxyService.pageList(dtoPageParam));
    }

    @Override
    public ApiResult<List<ArtifactProxyDTO>> conditionalArtifactProxyList(ArtifactProxyQuery artifactProxyQuery) {
        return ApiResult.success(artifactProxyService.list(artifactProxyQuery));
    }

    @Override
    public ApiResult<Boolean> addArtifactProxy(ArtifactProxyDTO artifactProxyDTO) {
        return ApiResult.success(artifactProxyService.add(artifactProxyDTO));
    }

    @Override
    public ApiResult<Boolean> updateArtifactProxy(ArtifactProxyDTO artifactProxyDTO) {
        return ApiResult.success(artifactProxyService.update(artifactProxyDTO));
    }

    @Override
    public ApiResult<Boolean> deleteArtifactProxy(String artifactProxyUuid) {
        return ApiResult.success(artifactProxyService.delete(artifactProxyUuid));
    }

    @Override
    public ApiResult<ArtifactProxyDTO> queryArtifactProxy(String artifactProxyUuid) {
        return ApiResult.success(artifactProxyService.query(artifactProxyUuid));
    }

}